package com.alibaba.algo.controller.user;

import com.alibaba.algo.cooperation.common.BaseResult;
import com.alibaba.algo.cooperation.usercomponent.service.user.FileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import net.sf.jsqlparser.statement.create.table.CreateTable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author : WangZhiPan
 * @date : 2021/11/2 14:26
 */
@Controller
@RequestMapping(value = "/usercenter-admin-app/admin/file")
@Api(tags = "文件管理", value = "文件管理")
public class FileController {


    @Autowired
    @Qualifier(value = "fileServiceImpl")
    public FileService fileService;


    /**
     * 下载模板/支持sys.template配置模板路径，请求api传递文件名即可
     *
     * @param request
     * @param response
     * @param fileName 文件名称，默认Template-SysOrg.xlsl
     */
    @GetMapping("/template")
    @ApiOperation(value = "下载模板")
    public void downloadTemplate(HttpServletRequest request, HttpServletResponse response, @ApiParam(value = "fileName") @RequestParam(defaultValue = "Template-SysOrg.xlsl") String fileName) {
        fileService.downloadTemplate(request, response, fileName);
    }


}
